package com.haina.shop.controller.user;

import com.haina.shop.context.BaseContext;
import com.haina.shop.result.ServiceResult;
import com.haina.shop.service.UserCollectionService;
import com.haina.shop.vo.PageVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("p/user/collection")
public class MyCollectionController {

    @Resource
    private UserCollectionService userCollectionService;

    @GetMapping("/count")
    public ServiceResult myCollection(){
        String userId= String.valueOf(BaseContext.getCurrentId());
        long count = userCollectionService.selectByUserId(userId);
        return ServiceResult.success(count);
    }

    @GetMapping("/prods")
    public ServiceResult myCollectionDetail(@RequestParam("current")long current,
                                            @RequestParam("size")long size){
        String userId= String.valueOf(BaseContext.getCurrentId());

        PageVo pageVo = new PageVo();
        pageVo.setSize(size);
        pageVo.setPages(current);
        pageVo.setCurrent(current-1);
//        userCollectionService.selectForDetail(userId,pageVo);

        return ServiceResult.success();
    }

}
